#include<bits/stdc++.h>
using namespace std;
struct hh
{
    double d;
    double v;
    double a;
}b[100010];
int m,n,T,l,c[100010],ans1,ans2,cnt,sum[100010];
double vm;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d%d%Lf",&m,&n,&l,&vm);
        ans1=ans2=0;
        cnt=1;
        for(int i=1;i<=m;++i)
        {
            scanf("%Lf%Lf%Lf",&b[i].d,&b[i].v,&b[i].a);
        }
        for(int i=1;i<=n;++i)
        {
            scanf("%d",&c[i]);
        }
        for(int i=1;i<=m;++i)
        {
            if(sqrt(b[i].v*b[i].v+2*b[i].a*(c[m]-b[i].d))>vm)
            {
                ans1++;
            }
        }
        ans2=n-1;
        if(ans1==0)
        {
            ans2=n;
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}
